<template>
    <view class="container">
        <!-- 顶部导航栏 -->
        <nav-bar title="公益活动"></nav-bar>
        <!-- 主要内容区域 -->
        <view class="main-content">
            <!-- 顶部轮播图 -->
            <banner-swiper :banners="banners"></banner-swiper>

            <!-- 活动分类导航 -->
            <view class="category-section">
                <view class="category-card" @click="navigateTo('/pages/storylibrary/activity/volunteer/index')">
                    <view class="category-icon-container">
                        <text class="category-icon">🤝</text>
                    </view>
                    <text class="category-title">志愿服务</text>
                    <text class="category-desc">参与志愿活动，传递温暖与关爱</text>
                </view>

                <view class="category-card" @click="navigateTo('/pages/storylibrary/activity/donation/index')">
                    <view class="category-icon-container">
                        <text class="category-icon">❤️</text>
                    </view>
                    <text class="category-title">爱心捐赠</text>
                    <text class="category-desc">奉献爱心，帮助有需要的人</text>
                </view>

                <view class="category-card" @click="navigateTo('/pages/storylibrary/activity/organization/index')">
                    <view class="category-icon-container">
                        <text class="category-icon">🏢</text>
                    </view>
                    <text class="category-title">公益组织</text>
                    <text class="category-desc">了解公益组织，寻找合作机会</text>
                </view>
            </view>

            <!-- 精彩活动 -->
            <view class="section-title">
                <text class="title-text">精彩活动</text>
                <text class="more-text" @click="navigateTo('/pages/storylibrary/activity/volunteer/index')">查看全部</text>
            </view>

            <view class="activity-list">
                <view class="activity-item" v-for="(activity, index) in recommendedActivities" :key="index"
                    @click="navigateTo(activity.url)">
                    <image class="activity-image" :src="activity.image" mode="aspectFill"></image>
                    <view class="activity-info">
                        <text class="activity-title">{{ activity.title }}</text>
                        <view class="activity-meta">
                            <text class="activity-time">{{ activity.time }}</text>
                            <text class="activity-location">{{ activity.location }}</text>
                        </view>
                        <text class="activity-status" :class="activity.statusClass">{{ activity.status }}</text>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
import NavBar from '@/components/NavBar.vue'
import BannerSwiper from '@/components/BannerSwiper.vue'

export default {
    components: {
        NavBar,
        BannerSwiper
    },
    data() {
        return {
            banners: [
                { image: '/static/banner-volunteer.jpg' },
                { image: '/static/banner-donation.jpg' },
                { image: '/static/banner-organization.jpg' }
            ],
            recommendedActivities: [
                {
                    title: '关爱老人志愿服务',
                    time: '2023-12-15',
                    location: '北京市朝阳区敬老院',
                    status: '招募中',
                    statusClass: 'status-recruiting',
                    image: '/static/activity-elderly.jpg',
                    url: '/pages/storylibrary/activity/volunteer/detail?id=1'
                },
                {
                    title: '儿童教育公益捐赠',
                    time: '2023-12-20',
                    location: '线上活动',
                    status: '进行中',
                    statusClass: 'status-ongoing',
                    image: '/static/activity-education.jpg',
                    url: '/pages/storylibrary/activity/donation/detail?id=2'
                },
                {
                    title: '公益组织交流会',
                    time: '2023-12-25',
                    location: '上海市公益中心',
                    status: '即将开始',
                    statusClass: 'status-upcoming',
                    image: '/static/activity-meeting.jpg',
                    url: '/pages/storylibrary/activity/organization/detail?id=3'
                }
            ]
        };
    },
    methods: {
        navigateTo(url) {
            uni.navigateTo({
                url: url
            });
        }
    }
};
</script>

<style>
/* 统一样式 */
@import '../index.css';

/* .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 90rpx;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.header-title {
    font-size: 36rpx;
    font-weight: bold;
    color: #333333;
} */

/* .content {
    margin-top: 90rpx;
    padding-bottom: 120rpx;
} */



.category-section {
    display: flex;
    justify-content: space-between;
    padding: 30rpx;
    background-color: #ffffff;
    border-radius: 20rpx;
    margin: -50rpx 20rpx 30rpx;
    position: relative;
    z-index: 10;
    box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
}

.category-card {
    width: 30%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s;
}

.category-card:active {
    transform: scale(0.95);
}

.category-icon-container {
    width: 100rpx;
    height: 100rpx;
    border-radius: 50%;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15rpx;
}

.category-icon {
    font-size: 50rpx;
}

.category-title {
    font-size: 28rpx;
    font-weight: bold;
    color: #333333;
    margin-bottom: 8rpx;
}

.category-desc {
    font-size: 22rpx;
    color: #999999;
    text-align: center;
    line-height: 1.2;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20rpx 30rpx;
}

.title-text {
    font-size: 32rpx;
    font-weight: bold;
    color: #333333;
}

.more-text {
    font-size: 24rpx;
    color: #666666;
}

.activity-list {
    padding: 0 20rpx;
}

.activity-item {
    display: flex;
    background-color: #ffffff;
    border-radius: 15rpx;
    margin-bottom: 20rpx;
    overflow: hidden;
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
    transition: transform 0.3s;
}

.activity-item:active {
    transform: scale(0.98);
}

.activity-image {
    width: 200rpx;
    height: 200rpx;
    flex-shrink: 0;
}

.activity-info {
    flex: 1;
    padding: 20rpx;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.activity-title {
    font-size: 28rpx;
    font-weight: bold;
    color: #333333;
    margin-bottom: 10rpx;
}

.activity-meta {
    display: flex;
    flex-direction: column;
    margin-bottom: 10rpx;
}

.activity-time,
.activity-location {
    font-size: 24rpx;
    color: #666666;
    margin-bottom: 5rpx;
}

.activity-status {
    align-self: flex-start;
    font-size: 22rpx;
    padding: 4rpx 12rpx;
    border-radius: 10rpx;
}

.status-recruiting {
    background-color: #e6f7ff;
    color: #1890ff;
}

.status-ongoing {
    background-color: #f6ffed;
    color: #52c41a;
}

.status-upcoming {
    background-color: #fff7e6;
    color: #fa8c16;
}
</style>